home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 1 / The Arsenal Files (Arsenal Computer).ISO / novell / lwpsdk.txt < prev    next >
Text File  |  1993-08-18  |  10KB  |  283 lines

  1.  
  2. Commonly Asked Questions and Answers for LWP Toolkit
  3. ----------------------------------------------------
  4.  
  5.  
  6. Q: Is there WINSOCK support for LWP?
  7.  
  8. A: It will be available on Netwire in the Fall 1993.   
  9.  
  10.  
  11. Q: How do I detect when the remote host has dropped the connection
  12.    unexpectedly?  ie. you pull the plug, or disconnect the network
  13.    cable.
  14.  
  15. A: Use setsockopt() on the client side to enable KEEPALIVES.  A packet
  16.    with just '?' for data is sent out every 75 seconds.  The other
  17.    side should recognize this as a KEEPALIVE packet and send back an
  18.    ACK.  If the client doesn't receive the acknowledgement within
  19.    another 75 seconds the socket will be closed.  Any socket calls you
  20.    make after that will return -1 and have errno=EBADF (as long as
  21.    that function uses the socket descriptor - not things like bcopy()).
  22.    Note that you must call setsockopt() BEFORE connect()!
  23.  
  24.  
  25. Q: What if I'm in the middle of a blocking recv() on the client side,
  26.    KEEPALIVES on, and I pull the plug on the remote host.  Will LWP
  27.    close down that socket and return recv() with -1, errno=EBADF?
  28.  
  29. A: Yes it will close down the socket and recv() returns with -1 but if
  30.    you have the latest tcpip from Netwire errno=ECONNRESET instead of
  31.    EBADF.  (Type "version tcpip" and you get something like this:
  32.    ....DOS TCPIP v4.1 (R41-1n, 930727) - version R41-1n or later, say
  33.    R41-1o, is what I mean here.)
  34.  
  35.  
  36. Q: I am using select() and the socket is always ready for writing,
  37.    and showing an exception.  Why?
  38.  
  39. A: These features were not implemented in tcpip R41.  In tcpip v4.1
  40.    R41-1n (or later) we have support for the write descriptors.
  41.  
  42.  
  43. Q: What is the difference between write() and send()?
  44.  
  45. A: None in the original tcpip v4.1 (the one that came on the diskettes), 
  46.    because we didn't support any flags on the send().  In v4.1 R41-1f
  47.    we added support for sending Out Of Band data but that is the only 
  48.    difference.   The latest LWP41 patch on Netwire includes features 
  49.    added in earlier versions such as 41-1f.
  50.  
  51.  
  52. Q: I am writing a DOS client for the UNIX server.  How will I know when
  53.    a client has gone down?
  54.  
  55. A: When the client closes its socket normally the server should not
  56.    have a problem.  It's when you Ctrl-C out of the DOS tcpip app.
  57.    that you get a surprise.  In the DOS/LWP world sockets are not tied
  58.    in with the application and are not closed by DOS when you kill the
  59.    application like this.  So even if you are running KEEPALIVES on
  60.    your UNIX the LWP tcpip will still have those sockets open and ACK
  61.    the UNIX's KEEPALIVES.  You need to add an interrupt handler for
  62.    Ctrl-C to your LWP app and from there close all open sockets.  You
  63.    may also want to look at the _abort_oper() function.
  64.  
  65.  
  66. Q: What is the maximum length of buffer I should be able to write 
  67.    with one call to sowrite() ?
  68.  
  69. A: 32K but you will need to increase the Mempool in your net.cfg.
  70.    Some data is buffered by the tcpip stack and with the default
  71.    Mempool of 4096 you can write about 12K at once.  Mempool is also
  72.    used to store outgoing data so once you increase that you can write
  73.    up to 32K at once, providing the remote host is advertising a
  74.    Window size of at least 32K.  The default window size in our tcpip
  75.    is only 2880 (bytes).  If you get tcpip version v.4.1N (R41-1n)
  76.    from Netwire then you can increase the Window size to 32767 with a
  77.    tcp_window statement in the net.cfg
  78.  
  79.  
  80. Q: How are LSL Buffers related to data flow?
  81.   
  82. A: These are buffers for incoming data.  Increasing the number of
  83.    buffers should increase the number of bytes you can read in one
  84.    soread() call, provided you have increased your Window size, and
  85.    there's that much data there to be read...
  86.  
  87.  
  88. Q: What is the maximum number of sockets I can use at once?
  89.  
  90. A: 128 tcp + 64 udp.  You may notice that if you open a socket and
  91.    make a connection, then close the socket that descriptor doesn't
  92.    become available until the other side has closed its socket or 2
  93.    minutes have expired.  If you use LWPCON you'll see the socket in a
  94.    CLOSING state.  This is part of the TCP protocol.  Read Comer's
  95.    Internetworking with TCP/IP Volume II page 194 for an explanation.
  96.   
  97.  
  98. Q: When I restart my server I get "Address already in use" from
  99.    bind().
  100.  
  101. A: First you need to close the original socket that is using that port
  102.    number.  If you hit Ctrl-C to quit the program and didn't write
  103.    your own interrupt handler to close that socket, then its probably
  104.    still in a LISTENING state. (Use LWPCON to see the state of your
  105.    sockets.)
  106.  
  107.    You could do: for (i=0; i<128; soclose(i), i++); before creating
  108.    the socket and then do setsockopt(REUSEADDR) before the bind.  Now
  109.    you should be able to reuse that port.  Of course this would also
  110.    close all other tcpip apps that were running.
  111.  
  112.  
  113. Q: How do I know when my connect() has completed if I'm using
  114.    non-blocking I/O ?
  115.  
  116. A: Keep calling connect() until errno=EISCONN.  The first call to
  117.    connect() will put errno=EINPROGRESS, then you'll get
  118.    errno=EALREADY and finally errno=EISCONN (if the connection
  119.    succeeds).
  120.  
  121.  
  122. Q: How long does it take for a blocking connect() to timeout? 
  123.  
  124. A: 75 seconds.  Not configurable but if you use non-blocking connects
  125.    with time(), you can loop on connect()s until errno=EISCONN, or x
  126.    seconds have passed.  In Windows use GetTickCount() instead of
  127.    time().
  128.   
  129.  
  130. Q: What is the maximum number of pending asynchronous calls I can have?
  131.  
  132. A: 16 total for all Windows apps, 16 per app in DOS.  An ENO_RCBS error
  133.    may indicate you've exceeded 16.
  134.  
  135.  
  136. Q: Is there a way to cancel pending asynchronous calls?
  137.  
  138. A: Yes, close that socket.
  139.  
  140.  
  141. Q: What socket options does LWP4.1 support?
  142.  
  143. A: KEEPALIVE and REUSEADDR.
  144.  
  145.  
  146. Q: How can I broadcast a message?
  147.  
  148. A: Open a UDP socket and then sendto() to your network's broadcast
  149.    address.
  150.     addr.sin_addr.s_addr = inet_addr("255.255.255.255");
  151.     rc = sendto (s, buffer, BUFFER_SIZE, 0,
  152.                      (struct sockaddr *)&addr, sizeof(addr));
  153.  
  154.  
  155. Q: We wrote an application for LWP4.01, will it run on LWP4.1?
  156.  
  157. A: Yes, provided you did not access unsupported/undocumented
  158.    structures in 4.01.  Although 4.1 uses PATH statements in the
  159.    net.cfg to find files in \NET\TCP directory (ex. hosts file), if
  160.    your application was compiled with 4.01 you still need to 'set
  161.    excelan=c:\xln'.  For Windows apps add 'Root=c:\xln' to the top of
  162.    your lwp.ini.
  163.  
  164.  
  165. Q: I get "symbol not defined" errors from the compiler when I do:
  166.    ioctl(FIONBIO).
  167.  
  168. A: Use soioctl() with Borland.  They have their own ioctl() so we
  169.    renamed ours.
  170.  
  171.  
  172. Q: Do any of the socket API functions use DOS interrupt 21?
  173.  
  174. A: Only the host database functions (gethostbyname, getnetbyname,
  175.    rhost...).
  176.  
  177.  
  178. Q: Is there a way for a Windows program to check if vtcpip.386 has
  179.    been loaded?
  180.  
  181. A: Not directly.  The best you can do is to use the Windows INI
  182.    routines to see if there is a device=vtcpip.386 in system.ini.
  183.  
  184.  
  185. Q: Can I do ICMP ?
  186.  
  187. A: No, we do not support raw sockets.
  188.  
  189.  
  190. Q: I'm having trouble writing an FTP or TELNET client.
  191.  
  192. A: Look for examples and specs in the following:
  193.    1. Internetworking with TCP/IP by Douglas Comer, Prentice Hall.
  194.    2. UNIX Network Programming by W.Richard Stevens, Prentice Hall.
  195.    3. The RFCs (Request for Comments).  These are the set of documents
  196.       that define the Internet Protocols.  Appendix 1 in Comer tell you
  197.       how to get these.  nic.ddn.mil is one place for anonymous ftp.
  198.  
  199.     IP (Internet Protocol)              RFC 791
  200.     TCP (Transmission Control Protocol)        RFC 793 (0-64 sockets)
  201.     UDP (User Datagram Protocol)             RFC 768 (0-32 sockets)
  202.     TELNET (Telnet Protocol)             RFC 854
  203.     FTP (File Transfer Protocol)            RFC 959
  204.     TFTP (Trivial File Transfer Protocol)         RFC 783
  205.     4. BSD sources are available on the Internet.  Use archie to find
  206.        what you need.
  207.  
  208.  
  209. Q: I'm having trouble compiling/linking the sample windows programs
  210.    for Borland's C++.
  211.  
  212. A: Add them as items to your project.  For instance, to make the
  213.    wtcpserv sample program open a new project and add wtcpserv.c,
  214.    wtcpserv.rc, twlbsock.lib as items in that project.  Linker
  215.    settings: Default Libraries.  Note that the link is NOT case
  216.    sensitive.  If you want to do case sensitive linking, create your
  217.    own import library :
  218.     
  219.     "IMPLIB myimp.lib wlibsock.dll"
  220.  
  221.    Source code extention should be *.C, not *.CPP.  Specify the path
  222.    for the header files and libraries under Options->Directories.  For
  223.    Windows apps you also need to #define WINDOWS under
  224.    Options->Compiler->Code Generation->Defines.
  225.  
  226. ------------------------------------------------------------------
  227. # Makefile for wtcpserv and wtcpclnt sample programs
  228. # Type:  make -DPROG=wtcpserv
  229. #        make -DPROG=wtcpclnt
  230.  
  231. $(PROG).exe : $(PROG).obj $(PROG).res $(PROG).def
  232.     tlink /Tw /v /n /c c0ws $&, $&, , twlbsock cws cs import, $&
  233.     rc $*.res
  234. .c.obj :
  235.     BCC -c -ms -v -W -DWINDOWS $<
  236. .rc.res :
  237.     rc -r -iC:\borlandc\INCLUDE $<
  238. -------------------------------------------------------------------
  239.  
  240. Q: There is no gethostname() function to get my local host's name.
  241.    How can I do this?
  242.  
  243. A: Do getmyipaddr() followed by gethostbyaddr() or raddr().
  244.  
  245.  
  246. Q: Why isn't gethostbyname() finding my resolv.cfg ?
  247.  
  248. A: It just looks at your local hosts file.  You need to use rhost()
  249.    for DNS.
  250.  
  251.  
  252. Q: I'm having trouble using gethostbyname()/gethostbyaddr() in
  253.    Windows.
  254.  
  255. A: The hostent fields are OFFSETS to the name,address aliases, etc.
  256.    To access the values of those field take the pointer to the hostent
  257.    structure and add the offset. In DOS you get the fields themselves,
  258.    not offsets and can access the values directly.  Here's how you get
  259.    the hostname:
  260.     pHost = (struct hostent far *) GlobalLock(hTemp);
  261.     pHostName = (char far *)pHost;
  262.     pHostName += pHost->h_name;
  263.  
  264.  
  265. Q: Does LWP tcpip use the Nagle algorithm?
  266.  
  267. A: No, as soon as you write any data it is sent (providing other
  268.    party's windows size > 0).
  269.     
  270.  
  271. Q: How do I find out what local port my socket is using?
  272.  
  273. A: Do a bind() with your IP address and port number set to 0.  The
  274.    transport will assign you a port number which you can get by then
  275.    calling getsockname().
  276.     
  277.      
  278.  
  279.  
  280.  
  281.  
  282.  
  283.